package com.ghsc.ghxc.jsb.ui.home.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.ui.home.bean.TasksStateResult

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.home.adapter
 * 类名：TaskListAdapter
 * 创建时间：2024/6/15 09:40
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class TaskListAdapter  : BaseQuickAdapter<TasksStateResult, BaseViewHolder>(
    R.layout.layout_task_item) {


    override fun convert(helper: BaseViewHolder, item: TasksStateResult) {
        if (item.type=="1")
            helper.setImageResource(R.id.imgIcon,R.drawable.icon_taks_1)
                .setText(R.id.tvTitle,item.name)
                .setText(R.id.tvBtnNext,if(item.count>=item.target)  "已完成" else  "去观看")
                .setText(R.id.tvTarget,if(item.count>=item.target)  "(1/1)"  else   "(0/1)")
        else if (item.type=="2")
            helper.setImageResource(R.id.imgIcon,R.drawable.icon_taks_2)
                .setText(R.id.tvTitle,item.name+"${item.target}次")
                .setText(R.id.tvBtnNext,if(item.count>=item.target)  "已完成" else  "去评论")
                .setText(R.id.tvTarget,if(item.count>=item.target) "("+item.target+ "/"+item.target+")" else   "("+item.count+ "/"+item.target+")")
        else if (item.type=="3")
            helper.setImageResource(R.id.imgIcon,R.drawable.icon_taks_3)
                .setText(R.id.tvTitle,item.name+"${item.target}次")
                .setText(R.id.tvBtnNext,if(item.count>=item.target)  "已完成" else  "去分享")
                .setText(R.id.tvTarget,if(item.count>=item.target) "("+item.target+ "/"+item.target+")" else   "("+item.count+ "/"+item.target+")")
        helper.setText(R.id.tvPrice,item.price.toString())
    }
}